package com.group.elmboot.mapper;

import com.group.elmboot.po.Orders;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrdersMapper {

	@Insert("insert into orders(userId,businessId,orderDate,orderTotal,daId,orderState,businessName,deliveryPrice,address,contactTel,contactName,contactSex) values(#{userId},#{businessId},#{orderDate},#{orderTotal},#{daId},0,#{businessName},#{deliveryPrice},#{address},#{contactTel},#{contactName},#{contactSex})")
	@Options(useGeneratedKeys=true,keyProperty="orderId",keyColumn="orderId")
	public int saveOrders(Orders orders);
	
	public Orders getOrdersById(Integer orderId);
	public List<Orders> listOrdersByUserId(String userId);
	@Update("update orders set orderState = 1 where orderId =#{orderId}")
	public int payOrders(Integer orderId);
	@Select("select orderState from orders where orderId =#{orderId}")
	public int getOrderStateById(Integer orderId);
	public List<Orders> listOrdersByBusinessId(Integer businessId);
}
